<?php
namespace app\admin\controller;


use app\admin\common\controller\Base;
use app\admin\common\model\Site as SiteModel;
use think\facade\Request;

class Site extends Base
{
    /*
     * 站点编辑
     */
    public function editSite(SiteModel $siteModel)
    {
        $info = $siteModel->getInfoById(1);

        $this->assign('info',$info);

        return $this->fetch('editSite');
    }

    /*
     * 编辑站点操作
     */
    public function editSiteDo(SiteModel $siteModel)
    {
        $params = Request::param();
        $rule = 'app\admin\validate\EditSite';
        $result = $this->validate($params,$rule);

        if (true !== $result) {
            $this->error($result);
        }

        $res = $siteModel->editSite($params);

        if ($res) {
            $this->success('更新成功','editSite');
        }

        $this->error('更新失败');
    }
}